from PyQt4 import QtCore
import md5

class MD5Thread(QtCore.QThread):
    def __init__(self, parent = None):
        QtCore.QThread.__init__(self,parent)
    
    def run(self):
        f = QtCore.QFile(self.filename)
        f.open(QtCore.QIODevice.ReadOnly)
        
        digest = md5.new()
        buffer = f.read(4096)
        while buffer != "":
            digest.update(buffer)
            buffer = f.read(4096)
        
        f.close()
        
        self.id = digest.hexdigest()